<template>
  <div class="about">
    zcxzczxczx
    <el-button type="primary" plain @click="handdleMsg('hello')"
      >主要按钮</el-button
    >
  </div>
</template>

<script lang="ts">
import { onMounted, computed, ref, watch, inject } from "vue";
// import { useRouter } from 'vue-router';
// import { useStore } from 'vuex';
export default {
  name: "",
  setup() {
    const WS: any = inject("WS");
    const handdleMsg = (msg: any) => {
      console.log(WS.ws);
      if (WS.ws && WS.ws.readyState == 1) {
        console.log("发送信息", msg);
        WS.ws.send(msg);
      }
      WS.ws.onmessage = function(res: any) {
        console.log("收到服务器内容", res);
      };
    };
    return { handdleMsg };
    // const Router = useRouter();
    // const Store = useStore();
  }
};
</script>

<style lang="scss" scoped></style>
